﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QPEngine
{
    /// <summary>
    /// 一个房间
    /// </summary>
    public abstract class RoomComponent : Component, IRoom
    {
        private string _name;
        private int _roomID;
        private ulong _needGold;

        /// <summary>
        /// 房间名字
        /// </summary>
        public string Name { get { return _name; } }
        /// <summary>
        /// 房间ID
        /// </summary>
        public int RoomID { get { return _roomID; } }
        /// <summary>
        /// 需要进入的条件
        /// </summary>
        public ulong NeedGold { get { return _needGold; } }

        public Dictionary<long, Player> Players = new Dictionary<long, Player>();

        public void Awake(string name,int id,ulong gold)
        {
            this._name = name;
            this._roomID = id;
            this._needGold = gold;
            Log.Debug($"创建{name}:{id}成功");
        }

        public virtual void Remove(long id)
        {
            Players.Remove(id);
        }

        public virtual void Add(Player p)
        {
            if (Players.ContainsKey(p.Id)) { Log.Error("进入房间重复");return; }
            Players.Add(p.Id,p);
        }
        
    }
}
